package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.dto.ParticipationCreateDTO;
import com.qzsf.backend.service.ParticipationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/25 15:29 周一
 * @Email 1429278462@qq.com
 * @Remark 活动参与情况控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("participation")
public class ParticipationController {
    @Autowired
    private ParticipationService participationService;
    @GetMapping
    public Result getParticipationByCondition(@RequestParam(required = false)String userName,@RequestParam(required = false)String eventName,@RequestParam int pageNo,@RequestParam int pageSize){
        return participationService.getParticipationByCondition(userName,eventName,pageNo,pageSize);
    }

    @DeleteMapping("/{id}")
    public Result deleteParticipationById(@PathVariable int id){
        return participationService.deleteParticipationById(id);
    }

    @GetMapping("incomplete/{eventId}")
    public Result getUsersWithIncompleteParticipation(@PathVariable int eventId){
        return participationService.getUsersWithIncompleteParticipation(eventId);
    }

    @PostMapping("batch")
    public Result addParticipation(@RequestBody List<ParticipationCreateDTO> participationList){
        return participationService.addParticipation(participationList);
    }

    @PostMapping("batch/un")
    public Result addUnParticipation(@RequestBody List<ParticipationCreateDTO> participationList){
        return participationService.addUnParticipation(participationList);
    }
}
